Using EXT, NTFS, or other format drives (internal or external) on Linux

This document is of primary interest to anyone who has connected USB drives or has media on other internal drives but user plex can’t access it due to Linux’s default security mechanisms.

WARNING: This procedure will not work for SNAP, Docker or other container mechanisms unless expressly handled within the confines of the container. This procedure is intended for use with the dpkg package.

We will walk through the steps needed to add these external USB hard drives and internal hard drives, either formatted as NTFS or ext4, to your Linux configuration so Plex Media Server can access it.

This procedure is completely valid and applicable to other formatted filesystems which Linux support. Some of those include hfs, exfat (best accessed as exfat-fuse on some systems), and many more.

Why We do this

On Linux, when using the graphical desktop environment, particularly the Nautilus file manager which comes with Gnome, Nautilus claims exclusive access to all unmounted media (disks and thumbdrives) and places them in a location only you can access.

Debian based systems: /media/my-user-name/disk-label .
Redhat based systems: /run/media/my-user-name/disk-label.

Because Linux is very strict about permissions, being the multi-user system it is, it assumes these unclaimed devices are temporary so mounts them and grants exclusive access to your username only.

The moment we log in, it asserts an exclusive-lock to your desktop username as it mounts the drives, leaving user plex locked out. No amount of permissions values will allow Plex to see the contents.

To work through this security, we must properly manage the media devices. For purposes of explanation, we’ll walk through adding 3 such disks.

Pre-requisite

When using NTFS disks, you may need to add the ntfs-3g or ntfs package. It will be installable from your normal software package manager (apt-get, yum, or dnf). If you do not have success with one, try the other.

How To

Three disks will be added.

  1. An external ext4-formatted disk.
  2. An external NTFS-formatted disk.
  3. An internal hard drive which, in this example, happens to be NTFS formatted. It may also be HPFS formatted as Linux supports this natively.

Any disk formats which Linux supports, regardless of whether internal or external, can be added as shown below.

For reference purposes, this document was created using Fedora 24 Linux with the Gnome desktop and the Nautilus graphical file manager. Linux shell (command line) commands are bold face text.

A. Identify the disk(s) you want to add in the graphical disk manager

We get the device names, which we only need temporarily, using the command df

[chuck@lizum ~]$ df
Filesystem  1K-blocks      Used  Available Use% Mounted on</font></font>
/dev/sda5   128884388  19057076  103257328  16% /
/dev/sda2      487652    146960     310996  33% /boot
/dev/sda7   970737276 159145788  762923072  18% /home
/dev/sda1   831543292 149144996  682398296  18% /run/media/chuck/8E7025AD70259D49
/dev/sdb1  1922728752  11372564 1911339804   1% /run/media/chuck/Media-3
/dev/sdc1  1953480700  91720372 1461760328  26% /run/media/chuck/Chuck 2T

We have identified internal disk partition /dev/sda1 and external USB disks “Chuck 2T” and “Media-3” as the disks we want made available to Plex .
Now we use this information to obtain the rest of the information we need.

The following steps must be performed as the Super-User (root).

[chuck@lizum ~]$ sudo sh
Passwd:
[root@lizum chuck]# 

B. Create the locations where we will graft everything into Linux

The directory `/usb’ has been chosen because Gnome “Nautilus” and Ubuntu (in general) claim exclusive access to anything found in /media. This prevents conflicts with those desktop components. You can use any directory name you wish provided it does not interfere with existing directories and isn’t in your home directory

In this example, the username ‘chuck’ should be replaced with your actual Linux username . This allows you to maintain full ownership and control of the media without needing to use the superuser (root) account each time.

# We're going to create the mount points here:   /usb/c /usb/media3 /usb/chuck2t [root@lizum chuck]# mkdir /usb /usb/c /usb/media3 /usb/chuck2t
[root@lizum chuck]# chown -R chuck:chuck /usb
[root@lizum chuck]# chmod -R 755 /usb

[root@lizum chuck]# ls -la /usb
drwxr-xr-x   3 chuck chuck 4096 Jul 27 11:14 .
dr-xr-xr-x. 30  root  root 4096 Jul 27 11:14 ..
drwxr-xr-x   4 chuck chuck 4096 Jul 27 11:04 c
drwxr-xr-x   4 chuck chuck 4096 Jul 27 11:04 chuck2t
drwxr-xr-x   4 chuck chuck 4096 Jul 27 11:04 media3
[root@lizum chuck]#

Having created the directories as root, verify empty (unmounted) directory permissions are 0755 before mounting

C. Get the ‘Block Id’ or device name (/dev/sdxx) of the disk partition(s) we are interested in

Get the label UUIDs for the USB drives (format does not matter) because their device names can change. This ensures they always mount at the same location. This step also provides us with the partition’s format.
We will need this.

[root@lizum chuck]# blkid /dev/sda1
/dev/sda1: UUID="8E7025AD70259D49" TYPE="ntfs" PARTUUID="000ac519-01"

[root@lizum chuck]# blkid /dev/sdb1
/dev/sdb1: LABEL="Media-3" UUID="50f1a141-bc8a-48ba-9b29-8a7bee8043e9" TYPE="ext4" PARTUUID="d456a9a6-9727-4143-be3e-f946400ec3ba"

[root@lizum chuck]# blkid /dev/sdc1
/dev/sdc1: LABEL="Chuck 2T" UUID="56EA5848EA582691" TYPE="ntfs" PARTUUID="542c75ae-01"

We now have both the UUID and partition formatting. Both pieces are needed below.

D. Create the entry in the file system table where to mount the disk each time the system boots

Now we’re going to bring together the directories we created in step B with the information we gathered in step C for Linux to use.

Edit the file system table Linux uses to mount all drives using your favorite text editor. Text editors commonly found are: vi, gedit, and xed.

Gedit is a graphical-based editor (WYSIWYG) and may be easier as it’s more like Microsoft editors.

For the USB drives:

Create lines for your system like the lines below, pasting UUID= value and TYPE (ntfs or ext4) from above, plus the directory locations just created where the external drives will always be found.

Best practice for USB drives is to use the UUID= method. USB drives will change physical device name from use to use. UUID= guarantees they always are mounted in the same location.

Use caution editing /etc/fstab. Mistakes can force you to take manual recovery/editing steps in command line mode ONLY** comment out the erred line(s) during recovery**

[root@lizum chuck]# vi /etc/fstab  (or use whatever text editor is available / favorite  and add the following lines, using your information)

# Addtions for external and internal drives
# Mount Media-3 (ext4)  at /usb/media3 for Plex
UUID=50f1a141-bc8a-48ba-9b29-8a7bee8043e9 /usb/media3  ext4  defaults,auto,rw,nofail 0 1

##
## - INFO:  Some distributions (Debian/Ubuntu is known) prefer 'ntfs-3g' over 'ntfs'
##
# Mount Chuck-2T (NTFS) at /usb/chuck2t for Plex
UUID=56EA5848EA582691                     /usb/chuck2t ntfs  defaults,auto,rw,nofail 0 1

# Mount /dev/sda1 directly  READ-ONLY,  and use the device name because it will never change
/dev/sda1                                 /usb/c       ntfs  defaults,auto,ro,nofail 0 1

NOTE: Mounting hfsplus partitions often requires the ‘force’ option to be included

Save and test.

# See where the disks are currently mounted (df) and unmount each
root@lizum chuck]# df
root@lizum chuck]# umount /run/media/chuck/Media-3
root@lizum chuck]# umount /run/media/chuck/Chuck2T

# mount each one individually to verify no errors
[root@lizum chuck]# mount /usb/media3
[root@lizum chuck]# mount /usb/chuck2t
[root@lizum chuck]# mount /usb/c
[root@lizum chuck]# ls  /usb/*         # this will produce a lot of output if correct.  Be prepared

E. Restart the computer and verify all is as expected

[chuck@lizum ~]$ ls /usb/*    # The output here should be the same as the previous test above


[chuck@lizum ~]$ df 
Filesystem  1K-blocks      Used  Available Use% Mounted on</font></font>
/dev/sda5   128884388  19057076  103257328  16% /
/dev/sda2      487652    146960     310996  33% /boot
/dev/sda7   970737276 159145788  762923072  18% /home
/dev/sda1   831543292 149144996  682398296  18% /usb/c
/dev/sdb1  1922728752  11372564 1911339804   1% /usb/media3
/dev/sdc1  1953480700 491720372 1461760328  26% /usb/chuck2t

[chuck@lizum ~]$

F. Correct (set) Linux file permissions (ext4 drives only)

Drives are now mounted. Verify PMS can read them.
NTFS drives do not require permissions to be set for Linux because they use a different mechanism.
We will only address the ext4 formatted drive.

[chuck@lizum ~]$ su
Password:

# change the default permissions to owner='rwx', everyone else to 'r-x' 
#  'x' means to traverse the directory to subdirectories & files
[root@lizum chuck]# find /usb/media3 -type d -exec chmod 755 {} \;

# change the default permissions to owner= 'rw-',  everyone else 'r-only'
[root@lizum chuck]# find /usb/media3 -type f -exec chmod 644 {} \;

G. Open Plex and add the external disk to your library

With the drives now mounted and permissions set, open PMS and add the media directories (folders) to the appropriate sections.

H. Update your Library

Manually invoke a Library update if your configuration isn’t already set to do so (Settings - Server - Library)

Revisions:

03-Jul-2019 - Addition of exfat / exfat-fuse reference.

23 Likes